import { Message,MessageBox } from 'element-ui'

const showMessage = function(content, type) {
  Message({
    message: content,
    type: type,
    showClose: true,
    duration: 3000
  })
}

const requestTips = function (item,cb) {
    if (item.success) {
        showMessage(item.message,"success")
        cb && cb()
    } else {
        showMessage(item.message,"error")
    }
}

//询问弹框
const askDialog = function (msg,cb) {
    MessageBox.confirm(msg, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        cancelButtonClass: 'el-button--mini',
        confirmButtonClass: 'el-button--mini',
        type: 'warning'
    }).then(
        cb
    ).catch(()=>{})
}

export {
    requestTips,
    askDialog
};
  